@echo off

setlocal

set CFLAGS=-mmcu=msp430x1612 -c -Wall -pedantic
set LFLAGS=-mmcu=msp430x1612 -Wall -pedantic

echo =============================================================================
echo Removing files from previous compile
echo =============================================================================
del /F /Q image.elf
del /F /Q bin\*

echo =============================================================================
echo Compiliation settings: %CFLAGS%
echo NB pedantic will report C++ style comments as a warning due to C89 standard
echo this can be ignored but should ideally be fixed.
echo =============================================================================

echo =============================================================================
echo Compiling main.c
echo =============================================================================
msp430-gcc %CFLAGS% main.c -o bin/main.o
echo =============================================================================
echo Compiling adc/adc_interface.c
echo =============================================================================
msp430-gcc %CFLAGS% adc/adc_interface.c -o bin/adc_interface.o
echo =============================================================================
echo Compiling adcs/adcs.c
echo =============================================================================
msp430-gcc %CFLAGS% adcs/adcs.c -o bin/adcs.o
echo =============================================================================
echo Compiling i2c/i2cinterface.c
echo =============================================================================
msp430-gcc %CFLAGS% i2c/i2cinterface.c -o bin/i2cinterface.o
echo =============================================================================
echo Compiling log/log.c
echo =============================================================================
msp430-gcc %CFLAGS% log/log.c -o bin/log.o
echo =============================================================================
echo Compiling payload/pay.c
echo =============================================================================
msp430-gcc %CFLAGS% payload/pay.c -o bin/pay.o
echo =============================================================================
echo Compiling recovery/recover.c
echo =============================================================================
msp430-gcc %CFLAGS% recovery/recover.c -o bin/recover.o
echo =============================================================================
echo Compiling sd/sd.c
echo =============================================================================
msp430-gcc %CFLAGS% sd/sd.c -o bin/sd.o
echo =============================================================================
echo Compiling timing/timing.c
echo =============================================================================
msp430-gcc %CFLAGS% timing/timing.c -o bin/timing.o
echo =============================================================================
echo Compiling coms/coms.c
echo =============================================================================
msp430-gcc %CFLAGS% coms/coms.c -o bin/coms.o
echo =============================================================================
echo =============================================================================
echo Compiling objects to image.elf
echo Compiliation settings: %LFLAGS%
echo =============================================================================
msp430-gcc %LFLAGS% bin/main.o bin/adc_interface.o bin/adcs.o bin/i2cinterface.o bin/log.o bin/pay.o bin/recover.o bin/sd.o bin/timing.o bin/coms.o -o image.elf
echo =============================================================================
echo Statistics about image file created
echo =============================================================================
msp430-ram-usage image.elf
echo =============================================================================
pause